#=====================================
# OpenWrt Makefile
#=====================================

include $(TOPDIR)/rules.mk

PKG_NAME:=mr
PKG_VERSION:=1
PKG_RELEASE:=1

PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk


define Package/simple
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=simple
endef

define Package/simple/description
	simple program
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef


define Build/Compile
	$(TARGET_CC) $(TARGET_CFLAGS) -c -o $(PKG_BUILD_DIR)/main.o $(PKG_BUILD_DIR)/main.c
	$(TARGET_CC) $(TARGET_CFLAGS) -c -o $(PKG_BUILD_DIR)/tjpgd.o $(PKG_BUILD_DIR)/tjpgd.c
	$(TARGET_CC) $(TARGET_CFLAGS) -c -o $(PKG_BUILD_DIR)/lodepng.o $(PKG_BUILD_DIR)/lodepng.c
	$(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/simple $(PKG_BUILD_DIR)/main.o $(PKG_BUILD_DIR)/tjpgd.o $(PKG_BUILD_DIR)/lodepng.o
endef

define Package/simple/install
	$(INSTALL_DIR) $(1)/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/simple $(1)/bin/
endef

$(eval $(call BuildPackage,simple))
